from PyQt5.QtWidgets import QApplication

def center_window(window):
    """使窗口居中显示"""
    screen_geometry = QApplication.desktop().availableGeometry()
    window_geometry = window.frameGeometry()
    window_geometry.moveCenter(screen_geometry.center())
    window.move(window_geometry.topLeft())